package kata09.discount;

import java.math.BigDecimal;

/**
 *  2 个 45
 */
public class BGoodsDiscount implements IGoodsDiscountStrategy {


    @Override
    public BigDecimal getGoodsDiscountPrice(int buyNumber, BigDecimal sourcePrice) {
        if(buyNumber >= 2){
            BigDecimal discountPrice = new BigDecimal(45);
            int discountPriceNumber = buyNumber / 2;
            int sourcePriceNumber = buyNumber % 2;
            return discountPrice.multiply(new BigDecimal(discountPriceNumber))
                    .add(sourcePrice.multiply(new BigDecimal(sourcePriceNumber)));

        }
        return sourcePrice.multiply(new BigDecimal(buyNumber));
    }
}
